

capture log close
log using $log/EDS_02_descriptives, text replace

clear
clear matrix
clear mata
set mem 2g
set matsize 800
set more off
set maxvar 20000
set trace off
set varabbrev off
		
#d;
global descvar "search_dist50 
	       applications_total
		   applications_distant
		   applications_local
		   search_radius 
		   search_channel_3 
		   search_channel_5 
		   channel_active 
		   meetings_3plus
		   ageny_offer_10
		   vacancy_referrals
		   ageny_offer_13
		   info_workfare
		   info_jsc
		   info_stt
		   info_sus
		   sanction

		   _Isu_schule_0 _Isu_schule_1 _Isu_schule_2 _Isu_schule_3 
		   _Isu_ausbila2
	       female 
		   _Isu_kat_al_1 _Isu_kat_al_2 _Isu_kat_al_3 _Isu_kat_al_4 
		   married 
		   east_germany
		   region_ba_aloq_zivall 
		   region_ba_vacancies 
		   gdp_real_pc
		   sector_agriculture 
		   sector_manufacturing 
		   sector_service

";
#d cr

use $data\data_individual, clear		
	
	
	
foreach type in applications_total applications_distant log_distance_km search_radius vacancy_referrals {
sum `type',d
	replace `type'=r(p99) if `type'>r(p99) & `type'!=.
		}
		gen applications_local = applications_total - applications_distant
	
foreach var in $descvar {

sum `var'
matrix d_`var'=r(mean)
}



#d;
matrix d = 
d_search_dist50 
\d_applications_total
\d_applications_distant
\d_applications_local
\d_search_radius 
\d_search_channel_3 
\d_search_channel_5 
\d_channel_active 
\d_meetings_3plus
\d_ageny_offer_10
\d_vacancy_referrals
\d_ageny_offer_13
\d_info_workfare
\d_info_jsc
\d_info_stt
\d_info_sus
\d_sanction;


matrix e = d__Isu_schule_0\d__Isu_schule_1\d__Isu_schule_2\d__Isu_schule_3\d__Isu_ausbila2
\d_female
\d__Isu_kat_al_1\d__Isu_kat_al_2\d__Isu_kat_al_3\d__Isu_kat_al_4\d_married\d_east_germany
\d_region_ba_aloq_zivall\d_region_ba_vacancies\d_gdp_real_pc
\d_sector_agriculture\d_sector_manufacturing\d_sector_service;

matrix rownames d = 
	"Applied to distant" 
	"Search radius" 
	"#applications distant"
	"#applications local"
	"#applications total"
	"Channel caseworker" 
	"Channel job info system" 
	"Channel active" 
	"Meetings 3+" 
	"Any offer from agency" 
	"#offers from agency"
	"Placement voucher" 
	"Notification workfare" 
	"Notification JSC" 
	"Notification training" 
	"Notification SUS"
	"Sanction received" 
	;

matrix rownames e =
"No school degree" "Lower sec degree" "Middle sec degree" "Upper sec degree" "University degree"
"Female" "Age 16-25" "Age 26-35" "Age 36-45" "Age 46-55" "Married" "East-Germany"
"Unemployment rate" "GDP" "Vacancy rate" "Share agriculture" "Share manufacturing" "Share service"
;	
	#d cr
	
	matrix colname d = "Mean" 
	estout matrix(d, fmt(4)) using $data/Table_A1_survey.tex, style(tex) replace

	matrix colname e = "Mean" 
	estout matrix(e, fmt(4)) using $data/Table_A2_survey.tex, style(tex) replace
	
	log close
